<?php header("Content-type:text/html; Charset=utf-8");?>
<?php
	//wsyS Y

	//地址信息获取
	function lj_Json1(){
		$url = $_SERVER['DOCUMENT_ROOT']."DAY/DAY4/File/json/Data_xx.json";
		$json_Str1 = file_get_contents($url);
		$arr_sl1 = json_decode($json_Str1,true);
		return $arr_sl1;
	}//lj_Json1
	//实例化SQLite3
	//class MyDB_cs extends SQLite3{
	class Sqlite_cs extends SQLite3{
		function __construct(){
			//$N_DZ1 =  $_SERVER['DOCUMENT_ROOT'].'H5j/zH5js/GC1/Database/Sqlite/dbv1';
			$arr_sl1 = lj_Json1();
			$BL1 = $arr_sl1['Sqltiel_1']['server'];
			$BL4 = $arr_sl1['Sqltiel_1']['dbname'];
			//echo "<script>alert('YY:".$BL1."')</script>";
			$N_DZ1 =  $_SERVER['DOCUMENT_ROOT'].$BL1.$BL4;
			$this->open($N_DZ1);
		}//__construct()
	}/*class Sqlite_cs wei*/ 

	class Sqlite_1{
		var $N_GS ="wxyS辅助开发框架 版本：V2.0"; 
		var $N_LBZ ="PHP操作Sqlite模块1"; 
		var $N_BQ = "版权归属：230104198110270213";
		var $Sqlitecon;
		function __construct(){}/*_construct*/
		function Open_1(){
			try{
				$this->Sqlitecon = new Sqlite_cs();/*实例化Sqlite_cs*/ 
				if(!$this->Sqlitecon){
					//$N_FHZ001 = $db_CZ1->lastErrorMsg();
					$this->Sqlitecon = 'Sqlite1';
					//echo $db_CZ1->lastErrorMsg();
				}else{
					//$connErrBJ1 = '1';
					//echo "Sqlite打开成功！<br/>";//"Sqlite opens success!<br/>";
				}/*if(!$db_CZ1) wei*/
			}catch(Exception $e){//// 捕获异常
				//echo '连接Sqlite数据库发生不可预知异常！<br/>';
				//$N_FHZ001 = '连接Sqlite数据库发生不可预知异常！<br/>';
				$this->Sqlitecon = 'Sqlite1';
			}//try wei
			return $this->Sqlitecon;
		}//Open_1
		function Close_1(){
			if($this->Sqlitecon!="Sqlite1"){
				$connErrBJ1 = '0';
				try{
					$this->Sqlitecon->close();
					$connErrBJ1 = '0';
				}
				catch(Exception $e)
				{
					$connErrBJ1 = 'Sqlite2';
				}
			}//if($Sqlitecon!
			return $connErrBJ1;
		}//Close_1
		
		
		//通用I，D,U
		function IDUys1($Sql1){
			$DZsql1 = $Sql1;
			$connErrBJ1 = '1';
			$zxpd1 = $this->Sqlitecon->exec($DZsql1);
			if($zxpd1){
				$connErrBJ1 = '0';
			}else{
				$connErrBJ1 = '1';
			}//
			return $connErrBJ1;
		}//IDUys1
		//查询记录数
		function CXysSL1($Sql1){
			$DZsql1 = "select count(*) as Selsl1sl from " . $Sql1 . ";";
			$connErrBJ1 = '0';
			//发送sql语句
			
			$E_sel1 = $this->Sqlitecon->query($DZsql1);
			$row = $E_sel1->fetchArray(SQLITE3_ASSOC);
			$connErrBJ1 = (string)$row['Selsl1sl'];
			/*
			while($row = $E_sel1->fetchArray(SQLITE3_ASSOC)){
				$connErrBJ1 = (string)$row['Selsl1sl'];
			}//while wei
			*/
			return $connErrBJ1;
		}//CXysSL1
		//通过序号获取数据
		function CXysZD1($tablename,$SqlQ1='*',$SqlH1='$NULL$'){
			$DZsql1 =  "select ".$SqlQ1." from ". $tablename;
			if($SqlH1!='$NULL$'){
				$DZsql1 = $DZsql1 . " " . $SqlH1;
			}
			$DZsql1 = $DZsql1 . ";";
			$connErrBJ1 = '';
			$leijl1 = 0;
			
			$E_sel1 = $this->Sqlitecon->query($DZsql1);
			while($row = $E_sel1->fetchArray(SQLITE3_NUM)){//SQLITE3_ASSOC,SQLITE3_BOTH,SQLITE3_NUM
				$ii1 = sizeof($row);
				//$connErrBJ1 = $connErrBJ1.  (string)$leijl1 . (string)$ii1;
				$iii1 = 0;
				if($leijl1 != 0){
					$connErrBJ1 = $connErrBJ1 . '$1$';
				}
				while($iii1<$ii1){
					if($iii1>0){
						$connErrBJ1 = $connErrBJ1 . "$2$";
					}//
					$connErrBJ1 = $connErrBJ1 . $row[$iii1];
					$iii1 = $iii1 + 1;
				}//
				$iii1 = 0;
				$leijl1 = $leijl1 + 1;
			}//while wei
			$leijl1 = 0;
	
			return $connErrBJ1;
		}//CXysZD1
		
		
		
		//字段查询1
		function CXysZD2($tablename,$SqlQ1='*',$SqlH1='$NULL$',$RDarray1=array(0),$rdsl='$NULL$'){
			$DZsql1 =  "select ".$SqlQ1." from ". $tablename;
			if($SqlH1!='$NULL$'){
				$DZsql1 = $DZsql1 . " " . $SqlH1;
			}
			$DZsql1 = $DZsql1 . ";";
			$connErrBJ1 = '';
			$leijl1 = 0;
			
			$E_sel1 = $this->Sqlitecon->query($DZsql1);
			if(sizeof($RDarray1)!=0){
				while($row = $E_sel1->fetchArray(SQLITE3_ASSOC)){//SQLITE3_ASSOC,SQLITE3_BOTH,SQLITE3_NUM
					$ii1 = sizeof($RDarray1);
					$ii1 = $rdsl =='$NULL$'? $ii1:(int)$rdsl;
					//$connErrBJ1 = $connErrBJ1.  (string)$leijl1 . (string)$ii1;
					$iii1 = 0;
					if($leijl1 != 0){
						$connErrBJ1 = $connErrBJ1 . '$1$';
					}
					while($iii1<$ii1){
						if($iii1>0){
							$connErrBJ1 = $connErrBJ1 . "$2$";
						}//
						$connErrBJ1 = $connErrBJ1 . $row[$RDarray1[$iii1]];
						$iii1 = $iii1 + 1;
					}//
					$iii1 = 0;
					$leijl1 = $leijl1 + 1;
				}//while wei
			}else{
				$connErrBJ1 = '$WXYNULL$';
			}//if(sizeof($RDarray1)!=0)
			$leijl1 = 0;
	
			return $connErrBJ1;
		}//CXysZD2
		
		function  __destruct(){}/*_destruct*/
	}//Sqlite_1 wei
/*
$sl = new Sqlite_1();
echo $sl->Open_1();
*/

?>